#include "linkedwGraph.h"

int main(){
    linkedwGraph<int>* myGraph = new linkedwGraph<int>(10);

    /* 点的输入 */
    string names[16] = { "北京","长沙","秦皇岛","上海", "唐山", "天津", "重庆", "哈尔滨", "长春", "沈阳", "石家庄", "太原", "银川", "兰州", "西安", "郑州"};
    for(auto item : names){
        myGraph->insertNode(item);
    }

    /* 测试的数据，边的输入 */
    bool temp;
    // temp = myGraph->insertEdge("长沙", "北京", 100);
    // temp = myGraph->insertEdge("秦皇岛", "长沙", 314);
    // temp = myGraph->insertEdge("长沙", "上海", 500);
    // temp = myGraph->insertEdge("北京", "秦皇岛", 614);
    // temp = myGraph->insertEdge("秦皇岛", "唐山", 42);
    // temp = myGraph->insertEdge("唐山", "长沙", 85);


    temp = myGraph->insertEdge("上海", "北京", 1064.67);
    temp = myGraph->insertEdge("北京", "上海", 1064.67);
    temp = myGraph->insertEdge("天津", "秦皇岛", 264.50);
    temp = myGraph->insertEdge("秦皇岛", "天津", 264.50);
    temp = myGraph->insertEdge("秦皇岛", "重庆", 2019.20);
    temp = myGraph->insertEdge("哈尔滨", "长春", 265.30);
    temp = myGraph->insertEdge("秦皇岛", "长春", 702.60);
    temp = myGraph->insertEdge("沈阳", "长春", 308.40);
    temp = myGraph->insertEdge("长春", "沈阳", 308.40);
    temp = myGraph->insertEdge("石家庄", "秦皇岛",557.30 );
    temp = myGraph->insertEdge("北京", "石家庄",290.70 );
    temp = myGraph->insertEdge("太原", "石家庄", 219.50);
    temp = myGraph->insertEdge("石家庄", "太原", 219.50);
    temp = myGraph->insertEdge("太原", "银川", 697.90);
    temp = myGraph->insertEdge("银川", "兰州", 427.20);
    temp = myGraph->insertEdge("兰州", "西安", 641.80);
    temp = myGraph->insertEdge("兰州", "西安", 641.80);
    temp = myGraph->insertEdge("西安", "郑州", 479.60);
    temp = myGraph->insertEdge("郑州", "上海", 940.0);
    temp = myGraph->insertEdge("郑州", "石家庄", 419.30);
    temp = myGraph->insertEdge("石家庄", "郑州", 419.30);
    temp = myGraph->insertEdge("郑州", "天津", 698.80);


    if(temp) puts("边的输入可能存在问题\n");
    // temp = myGraph->insertEdge("北京", "上海", 314.514);
    // temp = myGraph->insertEdge("秦皇岛", "长沙", 1145.14);
    // temp = myGraph->insertEdge("上海", "长沙", 165.14);
    // temp = myGraph->insertEdge("上海", "北京", 365.14);
    // temp = myGraph->insertEdge("上海", "秦皇岛", 365.14);



    /* dfs算法测试代码 */
    int res = myGraph->dfs_find("上海", "长沙");
    if(res == FOUND){
        puts("Yes");
    } else if(res == NOT_FOUND){
        puts("No Path");
    } else if(res == ERROR){
        puts("Node Error");
    }


    puts("------------------");


    /* bfs算法测试代码 */
    res = myGraph->bfs_find("北京" ,"长沙");


    if(res == NOT_FOUND){
        puts("No Path");
    }else if(res == ERROR){
        puts("Node Error");
    }


    puts("------------------");


    /* prim算法测试代码 */
    int visit[4];
    int lowCost[4];
    myGraph->prim("长沙", visit, lowCost);
    for (int i = 0; i < 4; i++)
    {
        cout << lowCost[i] << endl;
    }


    puts("------------------");


    /* dijkstra算法测试代码 */
    myGraph->dijkstra("秦皇岛", "长沙");


    puts("------------------");


    /* 堆优化版本的dijkstra算法测试代码 */
    myGraph->dijkstra_fast("秦皇岛", "长沙");


    puts("------------------");


    /* 拓扑排序算法的测试代码 */
    myGraph->topo_find();
    return 0;
}